<template>
  <el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible="crud.status.cu > 0" :title="crud.status.title" width="700px">
    <el-form ref="form" :model="form" :rules="rules" size="small" label-width="120px">
      <el-form-item label="上级组织" prop="orgParentId">
        <org-tree v-model="form.orgParentId" placeholder="请选择上级组织" :node-key="form.orgParentId" />
      </el-form-item>
      <el-form-item label="组织类型" prop="orgType">
        <el-select v-model="form.orgType" filterable placeholder="请选择">
          <el-option v-for="item in dict.dict.type_org" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue" />
        </el-select>
      </el-form-item>
      <el-form-item label="组织类别" prop="orgCate">
        <el-select v-model="form.orgCate" filterable placeholder="请选择">
          <el-option v-for="item in dict.dict.type_org_cate" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue" />
        </el-select>
      </el-form-item>
      <el-form-item label="组织名称" prop="orgName">
        <el-input v-model="form.orgName" />
      </el-form-item>
      <el-form-item label="组织简称">
        <el-input v-model="form.orgShortName" />
      </el-form-item>
      <el-form-item label="组织地址">
        <el-input v-model="form.orgAddr" />
      </el-form-item>
      <el-form-item label="组织联系方式">
        <el-input v-model="form.orgPhones" />
      </el-form-item>
      <el-form-item label="组织邮箱">
        <el-input v-model="form.orgEmail" />
      </el-form-item>
      <el-form-item label="组织网站">
        <el-input v-model="form.orgWebsite" />
      </el-form-item>
      <el-form-item label="组织简介">
        <el-input v-model="form.orgIntroduction" />
      </el-form-item>
      <el-form-item label="组织照片">
        <el-input v-model="form.orgImgs" />
      </el-form-item>
      <el-form-item label="组织联系人">
        <el-input v-model="form.orgContacters" />
      </el-form-item>
      <el-form-item label="组织负责人">
        <el-input v-model="form.orgLeaders" />
      </el-form-item>
      <el-form-item label="组织标签">
        <tag-select v-model="form.orgTags" :selects="form.orgTags" tag-type="2" />
      </el-form-item>
      <el-form-item label="区域ID">
        <region-tree v-model="form.regionId" placeholder="请选择所在区域" :node-key="form.regionId" />
      </el-form-item>
      <el-form-item label="备注">
        <el-input v-model="form.remark" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="text" @click="crud.cancelCU">取消</el-button>
      <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { form } from '@crud/crud'
import OrgTree from '@/views/business/common/org/components/OrgTree/index'
import RegionTree from '@/views/business/common/org/components/RegionTree/index'
import TagSelect from '@/views/business/common/org/components/TagSelect/index'

const defaultForm = { orgId: null, orgParentId: null, orgType: null, orgCate: null, orgName: null, orgShortName: null, orgAddr: null, orgPhones: null, orgEmail: null, orgWebsite: null, orgIntroduction: null, orgImgs: null, orgContacters: null, orgLeaders: null, orgTags: null, regionId: null, regionName: null, isNode: null, remark: null }
export default {
  components: { TagSelect, RegionTree, OrgTree },
  mixins: [form(defaultForm)],
  props: {
    dict: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      rules: {
        orgParentId: [{ required: true, message: '上级组织不能为空', trigger: 'blur' }],
        orgType: [{ required: true, message: '组织类型不能为空', trigger: 'blur' }],
        orgCate: [{ required: true, message: '组织类别不能为空', trigger: 'blur' }],
        orgName: [{ required: true, message: '组织名称不能为空', trigger: 'blur' }]
      }
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  /deep/ .el-input-number .el-input__inner {
    text-align: left;
  }
</style>
